package com.es.hr.visitorscore;

import java.util.ArrayList;
import java.util.HashMap;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.es.hr.shop.ShopBiz;
import com.es.util.excel.ExportExcelJsp;
import com.es.util.excel.ShopExcelOrderBean;
import com.opensymphony.webwork.interceptor.ServletRequestAware;
import com.opensymphony.webwork.interceptor.ServletResponseAware;
import com.opensymphony.xwork.ActionSupport;

public class VisitorScoreExcelAction extends ActionSupport implements ServletRequestAware, ServletResponseAware{
	
	  /**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	HttpServletRequest request;
	 HttpServletResponse response;

	  @SuppressWarnings("unchecked")
	public String execute() throws Exception
	  {
		  request.setCharacterEncoding("GB2312");
				   
		  VisitorScoreBiz biz = new VisitorScoreBiz();		  
		 
		   ArrayList<HashMap<String,String>> list  = biz.exportExcel( new ArrayList());
		   String excelString = ExportExcelJsp.getExcelJspString(list,ShopExcelOrderBean.getShopOrderMap());
		  
		  //String filename="测试";
		  excelString = "<html><head><title></title></head><body > "+excelString+"</body></html>";
		  response.setContentType("application/vnd.ms-excel;charset=gb2312");
		  //response.setHeader("Content-disposition","attachment; filename="+new String(filename.getBytes("gbk"),"iso8859-1")+".xls" );
		  response.getWriter().write(excelString);
	      return "";
	  }

	  public void setServletRequest(HttpServletRequest request) {
	    this.request = request;
	  }

	  public void setServletResponse(HttpServletResponse response) {
	    this.response = response;
	  }
}
